package com.geekstudy.week1.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
import java.io.StringWriter;

/**
 *
 * 参考资料
 * https://www.runoob.com/jsp/jsp-custom-tags.html
 *
 */
public class HelloDemoTag extends SimpleTagSupport {


    @Override
    public void doTag() throws JspException, IOException {
        System.out.println("HelloDemoTag start");
        //JspWriter out = getJspContext().getOut();
        //out.println("<label>Hello Demo Tag</label>");
        StringWriter stringWriter = new StringWriter();
        getJspBody().invoke(stringWriter);
        getJspContext().getOut().print(stringWriter.toString());
        System.out.println("HelloDemoTag finish");
    }

}
